<?php
// Note: This file is included from the library/Vanilla/Vanilla.Control.SearchForm.php
// class and also from the library/Vanilla/Vanilla.Control.DiscussionForm.php's
// themes/discussions.php include template.

$UnreadUrl = GetUnreadQuerystring($Discussion, $this->Context->Configuration, $CurrentUserJumpToLastCommentPref);
$NewUrl = GetUnreadQuerystring($Discussion, $this->Context->Configuration, 1);
$LastUrl = GetLastCommentQuerystring($Discussion, $this->Context->Configuration, $CurrentUserJumpToLastCommentPref);

$BlogList .= '
<li id="Blog_'.$Discussion->DiscussionID.'" class="Blog'.$Discussion->Status.($Discussion->CountComments == 1?' NoReplies':'').($this->Context->Configuration['USE_CATEGORIES'] ? ' Category_'.$Discussion->CategoryID:'').($Alternate ? ' Alternate' : '').($this->RowNumber == 1 ? ' First' : '').($this->RowNumber == $this->Context->Configuration['BLOG_PER_PAGE'] ? ' Last' : '').' ">
<ul>
   <li class="BlogTitle"> <!--Blog Post Title-->
        <h2><a href="'.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', $Draft ? 'Draft=1#Item_1': '#Item_1', CleanupString($Discussion->Name).'/').'">'.$Discussion->Name.'</a></h2>
   </li>
   <li class="BlogInfo"> <!--Blog Post Author and Date-->
         <em>by</em><a href="'.GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Discussion->AuthUserID).'">'.$Discussion->AuthUsername.'</a>
        <em>on</em>'.date($this->Context->Configuration['BLOG_DATE'], $Discussion->DateCreated).'
    </li>
    <li class="BlogContent"> <!--Blog Post Content-->
         '.$CommentBody['main'];
        if ($CommentBody['extended'] != '')
                $BlogList .= '<p class="more"><a href="'.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '#more', CleanupString($Discussion->Name).'/').'">'.$this->Context->GetDefinition('More').'</a></p>';
$BlogList .= '</li><li>';
$this->CallDelegate('PreSocialbookmarkRender');

$BlogList .= '</li><li class="BlogFooter"><div class="BlogMoreInfo">';
if ($Discussion->Closed == 0   && $Discussion->CountComments == 1) {
       $BlogList .= '<span class="BlogAddComments"><a href="'.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '#pgbottom', CleanupString($Discussion->Name).'/').'">'.$this->Context->GetDefinition('AddComments').'</a></span>';
}

if ($Discussion->CountComments > 1) {
    $Discussion->CountComments--;
    $BlogList .= '<span class="BlogComments"><a href="'.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '#Item_2', CleanupString($Discussion->Name).'/').'">'.$this->Context->GetDefinition('Comments').': '.$Discussion->CountComments.'</a></span>';

}
if ($this->Context->Session->UserID > 0 && $Discussion->NewComments > 0 && $Discussion->CountComments > 1) {
    $BlogList .= '<span class="BlogNewComments"><a href="'.$NewUrl.'"><img src="'.$this->Context->Configuration["BASE_URL"].'extensions/Blog/theme/images/new.png" /> '.$Discussion->NewComments.'</a></span>';
}
$BlogList.= '<span class="BlogPermalink"><a href="'.GetUrl($this->Context->Configuration, 'extension.php', 'discussion/', 'DiscussionID',$Discussion->DiscussionID,'','CategoryID='.$this->Context->Configuration['BLOG_CATEGORY_ID'].'&PostBackAction=Blog&page=Permalink').'">' . $this->Context->GetDefinition("Permalink").'</a></span>';

if ($this->Context->Session->UserID > 0) {
    if ($Discussion->AuthUserID == $this->Context->Session->UserID || $PERMISSION_EDIT_COMMENTS || $PERMISSION_EDIT_DISCUSSIONS) {
        if ((!$Discussion->Closed && $Discussion->Active) || $PERMISSION_EDIT_COMMENTS || $PERMISSION_EDIT_DISCUSSIONS)
            $BlogList .= '<span class="BlogEdit"><a href="'.GetUrl($this->Context->Configuration, 'post.php', 'category/', 'CategoryID',$this->Context->Configuration['BLOG_CATEGORY_ID'],'','CommentID='.$Discussion->FirstCommentID.'&Draft='.$Draft).'">'.$this->Context->GetDefinition('Edit').'</a></span>';
    }
}
$BlogList .= '</div>';

$BlogList .= '<div class="BlogBookmarks">';
if ($this->Context->Configuration['BLOG_SOCIALBOOKMARKS_DIGG'] == 1)
    $BlogList .= '<a target="_blank" href="http://digg.com/submit?phase=2&url='.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '', CleanupString($Discussion->Name).'/').'&title='.CleanupString($Discussion->Name).'"><img src="'.$this->Context->Configuration["BASE_URL"].'extensions/Blog/theme/images/digg.gif" /></a>';
if ($this->Context->Configuration['BLOG_SOCIALBOOKMARKS_DELICIOUS'] == 1)
    $BlogList .= '<a target="_blank" href="http://del.icio.us/post?v=4&noui&jump=close&url='.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '', CleanupString($Discussion->Name).'/').'&title='.CleanupString($Discussion->Name).'"><img src="'.$this->Context->Configuration["BASE_URL"].'extensions/Blog/theme/images/delicious.gif" /></a>';
if ($this->Context->Configuration['BLOG_SOCIALBOOKMARKS_STUMBLE'] == 1)
    $BlogList .= '<a href="http://www.stumbleupon.com/newurl.php?url='.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '', CleanupString($Discussion->Name).'/').'&rating=1" target="_blank"><img src="'.$this->Context->Configuration["BASE_URL"].'extensions/Blog/theme/images/stumble.gif" /></a>';
if ($this->Context->Configuration['BLOG_SOCIALBOOKMARKS_TECHNORATI'] == 1)
    $BlogList .= '<a href="http://technorati.com/faves?add='.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '', CleanupString($Discussion->Name).'/').'&rating=1" target="_blank"><img src="'.$this->Context->Configuration["BASE_URL"].'extensions/Blog/theme/images/technorati.gif" /></a>';
    $BlogList .= '</div>';

$BlogList .= '</li>';
   //$this->DelegateParameters['Blog'] = &$Blog;
   $this->DelegateParameters['BlogList'] = &$BlogList;
   $this->DelegateParameters['RowNumber'] = &$this->RowNumber;

   $this->CallDelegate('PostDiscussionOptionsRender');

$BlogList .= '</ul>';

?>
